//
//  MeSettingCell.m
//  OnionHome
//
//  Created by fengjie on 2019/9/14.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "MeSettingCell.h"

@interface MeSettingCell ()
/**左边文字*/
@property (nonatomic,strong)UILabel*leftName;
/**右边图片*/
@property (nonatomic,strong)UISwitch*switchBtn;
/**<#属性#>*/
@property (nonatomic,strong)UIImageView * moreImage;

@end

@implementation MeSettingCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self createUI];
    }
    return self;
}
-(void)setIndexPath:(NSIndexPath *)indexPath{
    _indexPath = indexPath;
    if (indexPath.section == 2 ) {
        self.moreImage.hidden = YES;
        self.switchBtn.hidden = YES;
    }else if ((indexPath.section == 1 && indexPath.row ==2) || (indexPath.section == 1 && indexPath.row ==3)){
        self.moreImage.hidden = YES;
        self.switchBtn.hidden = NO;
    }else{
        self.moreImage.hidden = NO;
        self.switchBtn.hidden = YES;

    }
}
-(void)setNameStr:(NSString *)nameStr{
    _nameStr = nameStr;
    self.leftName.text = nameStr;
}
-(void)createUI{
    self.moreImage = [[UIImageView alloc] initWithImage:IMAGE_NAMED(@"more")];

    [self addSubview:self.leftName];
    [self addSubview:self.switchBtn];
    [self addSubview:self.moreImage];
    
    [self.leftName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(16);
        make.bottom.mas_equalTo(-16);
    }];
    [self.switchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.leftName);
        make.right.mas_equalTo(-18);
    }];
    [self.moreImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.leftName);
        make.right.mas_equalTo(-16);
        make.width.mas_equalTo(7);
        make.height.mas_equalTo(9);
    }];

    

}
#pragma mark ---懒加载
-(UILabel*)leftName{
    if(!_leftName){
        _leftName=[UILabel new];
        _leftName.textColor = UIColorFromRGB(0x454F44);
        _leftName.font = PingFangSC_Medium(16);
        _leftName.text = @"编辑资料";
    }
    return _leftName;
}
-(UISwitch*)switchBtn{
    if(!_switchBtn){
        _switchBtn=[UISwitch new];
    }
    return _switchBtn;
}
@end
